using UnityEngine;
using System.Collections;

public class Canhao : MonoBehaviour
{

    public float anguloAtual = 0F;
    public float velocidade = 500F;
    private HingeJoint joint = new HingeJoint();
	private	JointSpring spring = new JointSpring();

    void Start()
    {
		
        joint = this.GetComponent<HingeJoint>();
		joint.spring = spring;
		spring.spring = 500f;
    }

    void Update()
    {
		spring.targetPosition = anguloAtual;
		joint.spring = spring;

        if (Input.GetKey(KeyCode.UpArrow) && anguloAtual<=45)
		{
		anguloAtual+=1.0f;
			Debug.Log("Indo");
		}
        else
		{
           if (Input.GetKey(KeyCode.DownArrow) && anguloAtual>=-45) anguloAtual-=1.0f;
		}

        
    }
}